package com.bawei.module_main

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.lib_common.provider.MyProvider
import com.bawei.lib_common.utils.LoggerUtils
import com.bawei.lib_image.GlideApp
import com.bawei.module_main.http.MainApi
import com.bawei.module_main.http.MainNetModule
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import javax.inject.Inject
const val TAG = "MainActivity"
@AndroidEntryPoint
@Route(path = "/main/MainActivity")
class MainActivity : AppCompatActivity() {


    @Inject
    @MainNetModule.CommonMainApi
    lateinit var mainApi: MainApi

    private lateinit var iv:ImageView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        lifecycleScope.launch {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
//                val response = mainApi.pposts()
//                if (response.code == 200) {
//                    LoggerUtils.d(TAG,response.data.toString())
//                }
            }
        }
        iv = findViewById(R.id.iv)
        GlideApp.with(this)
            .load("https://skl-prod.oss-cn-shenzhen.aliyuncs.com/1743357010086/userAvatar.png?x-oss-process=image/resize,w_829,h_759/quality,q_70&name=userAvatar.png&length=587406&width=829&type=image/png&height=759")
            .into(iv)
    }

    fun toMessage(view: View) {
        ARouter.getInstance().build("/message/MainActivity").navigation()
    }

    fun test(view: View) {
        val myProvider = ARouter.getInstance().build("/message/myProvider").navigation() as MyProvider
        myProvider.test("jhahjah")
    }
}